const net = require('net');

let host = '127.0.0.1';
let port = '8080';

let client = new net.Socket();
client.connect(port,host,()=>{
    console.log('CONNECTED TO: ' + host + ':' + port);
    client.write('I am lmon client');
})

client.on('connect',()=>{
    console.log('connect ok')
})

client.on('data',(data)=>{
    console.log('I(client) recive data:',data);
    // client.end()
})


client.on('error',()=>{
    console.log('connect failed')
})

client.on('close',()=>{
    console.log('Connection closed');
})